home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / winsock / ircii2-6.zip / SRC\IRCII-2.6\SOURCE\HOLD.C < prev    next >
C/C++ Source or Header  |  1994-12-28  |  4KB  |  167 lines

  1. /*
  2.  * hold.c: handles buffering of display output.
  3.  *
  4.  * Written By Michael Sandrof 
  5.  *
  6.  * Copyright(c) 1990 
  7.  *
  8.  * See the COPYRIGHT file, or do a HELP IRCII COPYRIGHT 
  9.  */
  10.  
  11. #ifndef lint
  12. static    char    rcsid[] = "@(#)$Id: hold.c,v 1.7 1994/07/02 02:32:13 mrg Stab $";
  13. #endif
  14.  
  15. #include "irc.h"
  16.  
  17. #include "ircaux.h"
  18. #include "window.h"
  19. #include "screen.h"
  20. #include "vars.h"
  21. #include "input.h"
  22.  
  23. /* reset_hold: Make hold_mode behave like VM CHAT, hold only
  24.  * when there is no user interaction, this should be called
  25.  * whenever the user does something in a window.  -lynx
  26.  */
  27. void    reset_hold(win)
  28. Window    *win;
  29. {
  30.     if (!win)
  31.         win = curr_scr_win;
  32.     if (!win->scrolled_lines)
  33.         win->line_cnt = 0;
  34. }
  35.  
  36. /* add_to_hold_list: adds str to the hold list queue */
  37. void    add_to_hold_list(window, str, logged)
  38. Window    *window;
  39. char    *str;
  40. int    logged;
  41. {
  42.     Hold    *new;
  43.     unsigned int    max;
  44.  
  45.     new = (Hold *) new_malloc(sizeof(Hold));
  46.     new->str = (char *) 0;
  47.     malloc_strcpy(&(new->str), str);
  48.     new->logged = logged;
  49.     window->held_lines++;
  50.     if ((max = get_int_var(HOLD_MODE_MAX_VAR)) != 0)
  51.     {
  52.         if (window->held_lines > max)
  53.             hold_mode(window, OFF, 1);
  54.     }
  55.     new->next = window->hold_head;
  56.     new->prev = (Hold *) 0;
  57.     if (window->hold_tail == (Hold *) 0)
  58.         window->hold_tail = new;
  59.     if (window->hold_head)
  60.         window->hold_head->prev = new;
  61.     window->hold_head = new;
  62.     update_all_status();
  63. }
  64.  
  65. /* remove_from_hold_list: pops the next element off the hold list queue. */
  66. void    remove_from_hold_list(window)
  67. Window    *window;
  68. {
  69.     Hold    *crap;
  70.  
  71.     if (window->hold_tail)
  72.     {
  73.         window->held_lines--;
  74.         new_free(&window->hold_tail->str);
  75.         crap = window->hold_tail;
  76.         window->hold_tail = window->hold_tail->prev;
  77.         if (window->hold_tail == (Hold *) 0)
  78.             window->hold_head = window->hold_tail;
  79.         else
  80.             window->hold_tail->next = (Hold *) 0;
  81.         new_free(&crap);
  82.         update_all_status();
  83.     }
  84. }
  85.  
  86. /*
  87.  * hold_mode: sets the "hold mode".  Really.  If the update flag is true,
  88.  * this will also update the status line, if needed, to display the hold mode
  89.  * state.  If update is false, only the internal flag is set.  
  90.  */
  91. void    hold_mode(window, flag, update)
  92. Window    *window;
  93. int    flag,
  94.     update;
  95. {
  96.     if (window == (Window *) 0)
  97.         window = curr_scr_win;
  98.     if (flag != ON && window->scrolled_lines)
  99.         return;
  100.     if (flag == TOGGLE)
  101.     {
  102.         if (window->held == OFF)
  103.             window->held = ON;
  104.         else
  105.             window->held = OFF;
  106.     }
  107.     else
  108.         window->held = flag;
  109.     if (update)
  110.     {
  111.         if (window->held != window->last_held)
  112.         {
  113.             window->last_held = window->held;
  114.                     /* This shouldn't be done
  115.                      * this way */
  116.             update_window_status(window, 0);
  117.             if (window->update | UPDATE_STATUS)
  118.                 window->update -= UPDATE_STATUS;
  119.             cursor_in_display();
  120.             update_input(NO_UPDATE);
  121.         }
  122.     }
  123.     else
  124.         window->last_held = -1;
  125. }
  126.  
  127. /*
  128.  * hold_output: returns the state of the window->held, which is set in the
  129.  * hold_mode() routine. 
  130.  */
  131. int    hold_output(window)
  132. Window    *window;
  133. {
  134.     if (!window)
  135.         window = curr_scr_win;
  136.     return (window->held == ON) || (window->scrolled_lines != 0);
  137. }
  138.  
  139. /*
  140.  * hold_queue: returns the string value of the next element on the hold
  141.  * quere.  This does not change the hold queue 
  142.  */
  143. char    *hold_queue(window)
  144. Window    *window;
  145. {
  146.     if (window->hold_tail)
  147.         return (window->hold_tail->str);
  148.     else
  149.         return ((char *) 0);
  150. }
  151.  
  152. int    hold_queue_logged(window)
  153. Window    *window;
  154. {
  155.     if (window->hold_tail)
  156.         return window->hold_tail->logged;
  157.     else
  158.         return 0;
  159. }
  160.  
  161. /* toggle_stop_screen: the BIND function TOGGLE_STOP_SCREEN */
  162. void    toggle_stop_screen()
  163. {
  164.     hold_mode((Window *) 0, TOGGLE, 1);
  165.     update_all_windows();
  166. }
  167.